package com.xyq.judge.domain;


import com.xyq.common.core.enums.CodeRunStatus;
import lombok.Data;

import java.util.List;

// 代码沙箱执行结果
@Data
public class SandBoxExecuteResult {
    private CodeRunStatus runStatus; // 代码运行结果
    private String exeMessage ; //  异常信息
    private List<String> outputList ; //  执行结果
    private Long userMemory ; // 占用内存 kb
    private Long userTime ; // 消耗时间 ms

    // 失败方法
    public static SandBoxExecuteResult fail(CodeRunStatus runStatus  , String errorMsg){
        SandBoxExecuteResult result = new SandBoxExecuteResult();
        result.setExeMessage(errorMsg);
        result.setRunStatus(runStatus);
        return result ;
    }
    public static SandBoxExecuteResult fail(CodeRunStatus runStatus ){
        SandBoxExecuteResult result = new SandBoxExecuteResult();
        result.setExeMessage(runStatus.getMsg());
        result.setRunStatus(runStatus);
        return result ;
    }

    public static SandBoxExecuteResult fail(CodeRunStatus runStatus  ,List<String> outputList ,
                                            Long userMemory , Long userTime){
        SandBoxExecuteResult result = new SandBoxExecuteResult();
        result.setExeMessage(runStatus.getMsg());
        result.setRunStatus(runStatus);
        result.setOutputList(outputList);
        result.setUserMemory(userMemory);
        result.setUserTime(userTime);
        return result ;
    }
    public static SandBoxExecuteResult success(CodeRunStatus runStatus  ,List<String> outputList ,
                                            Long userMemory , Long userTime){
        SandBoxExecuteResult result = new SandBoxExecuteResult();
        result.setRunStatus(runStatus);
        result.setUserMemory(userMemory);
        result.setOutputList(outputList);
        result.setUserTime(userTime);
        return result ;
    }

}
